import { createSlice } from "@reduxjs/toolkit"

interface LanguageState {
  language: 'en' | 'zh',
  languageList: {name:string,code:string}[]
}

const initialState: LanguageState = {
  language: 'zh',
  languageList: [
    {
      name: '中文',
      code:'zh'
    },
    {
      name: 'English',
      code:'en'
    }
  ]
}



export const languageSlice = createSlice({
  name: 'language',
  initialState,
  reducers: {
    changeLanguage: (state,action) => {
      state.language = action.payload
    }
  },
})